/* Default icons are required. After that, import custom icons if applicable */
import "tinymce/icons/default/icons.min.js";
/* Required TinyMCE components */
import "tinymce/themes/silver/theme.min.js";
import "tinymce/models/dom/model.min.js";
/* Import a skin (can be a custom skin instead of the default) */
import "tinymce/skins/ui/oxide/skin.js";
/* Import premium plugins */
/* NOTE: Download separately and add these to /src/plugins */
/* import './plugins/<plugincode>'; */
/* content UI CSS is required */
import "tinymce/skins/ui/oxide/content";
/* The default content CSS can be changed or replaced with appropriate CSS for the editor content. */
import "tinymce/skins/content/default/content";

/* Import plugins */
import "tinymce/plugins/advlist";
import "tinymce/plugins/code";
import "tinymce/plugins/emoticons";
import "tinymce/plugins/emoticons/js/emojis";
import "tinymce/plugins/link";
import "tinymce/plugins/lists";
import "tinymce/plugins/image";
import "tinymce/plugins/media";
import "tinymce/plugins/table";
import "tinymce/plugins/wordcount";
import "tinymce/plugins/preview";
import "tinymce/plugins/codesample";
import "tinymce/plugins/fullscreen";
import "tinymce/plugins/searchreplace";
import "tinymce/plugins/autolink";
import "tinymce/plugins/directionality";
import "tinymce/plugins/visualblocks";
import "tinymce/plugins/visualchars";
import "tinymce/plugins/charmap";
import "tinymce/plugins/nonbreaking";
import "tinymce/plugins/insertdatetime";
import "tinymce/plugins/autosave";
import "tinymce/plugins/autoresize";
import "tinymce/plugins/quickbars";
import "tinymce/plugins/pagebreak";
import "tinymce/plugins/importcss";
import "./plugins/langs/zh-Hans";
import { TinyMCE } from "tinymce";

function addPlugins(tinymce: TinyMCE) {
  tinymce.PluginManager.add("powerpaste", (_editor) => {
    _editor.on("paste", function (e) {
      // 只处理来自剪贴板的数据
      if (e.clipboardData) {
        // 清除默认粘贴行为
        e.preventDefault();
        // 将处理后的内容插入编辑器
        _editor.insertContent(e.clipboardData.getData("text/html"));
      }
    });
  });
}
